<template>
    <ion-page>
      <ion-header>
        <ion-toolbar>
          <ion-buttons slot="start">
          <ion-back-button fill="outline" ></ion-back-button>
        </ion-buttons>
        </ion-toolbar>
      </ion-header>      
        <ion-content>
            <ion-grid>
           <ion-list :inset="true" v-if="items">
                <ion-item v-for="item in items" :key="item.id" >
                    <ion-label>
                        <ion-card>
                          <ion-card-content>
                          <ion-row>
                            <ion-col size="12"> TYPE:  NOTICE </ion-col>
                            <!-- <ion-col size="12"> {{'ID:'}}  {{item.id}} </ion-col> -->
                            <ion-col size="12">{{ 'TIME : ' }}</ion-col>
                            <ion-col size="12">{{ item.deteTime }}</ion-col>
                            <ion-col size="12">{{ 'SUBJECT : ' }}</ion-col>
                            <ion-col size="12" @click="goToContent(item.id)">{{ item.subject }}</ion-col>
                            <ion-col size="12">{{ 'OBS/INST : ' }}{{ item.inst }}</ion-col>                                           
                          </ion-row>
                        </ion-card-content>
                        </ion-card>
                    </ion-label>                    
                </ion-item>
           </ion-list>
        </ion-grid>
        </ion-content>
    </ion-page>
</template>

<script setup>
import { IonPage,IonContent,IonHeader,IonToolbar,IonGrid,IonBackButton,IonButtons,IonList,IonItem,IonLabel,IonCard,IonCardContent,IonRow,IonCol } from '@ionic/vue';
import { service1 } from '@/api/request'
import { onMounted,ref} from 'vue';
import { useRoute } from 'vue-router';
 import router from '@/router';
const route = useRoute();
const items=ref({item:{
  deteTime:'',
  subject:'',
  inst:'',
  cls:'',
  mission:'',
  id:'',
  triggerName:''
  },data:{
    triggerName:{}
  }
})

const fetchData =async () => {
      try {        
      const response = await service1.post('/alertApi/getNcs',{length:100},{params:{triggerName:route.params.triggerName}});
        items.value = response.data.data.list;
          console.log(response.data);
      } catch (error) {
        // 处理请求错误
        console.error('Error fetching data:',error);
      }
    }  
    onMounted(fetchData); 
const goToContent =(id) => { 
      router.push({
      name: 'contentpage',
      params:{id}
    });
  };
</script>